package com.zzh.custom.refresh;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.zzh.custom.R;
import com.zzh.custom.recycler.BaseChaosItem;
import com.zzh.custom.recycler.ChaosAdapter;
import com.zzh.custom.recycler.ChaosBean;
import com.zzh.custom.recycler.ChaosViewHolder;

import java.util.ArrayList;
import java.util.List;

public class DefaultContent<V extends View> extends Content<V> {


    private RecyclerView mRecyclerView;

    @Override
    public View createView(ViewGroup parent) {
        mRecyclerView = (RecyclerView) LayoutInflater.from(parent.getContext()).inflate(R.layout.zzh_refresh_content, parent, false);
        return mRecyclerView;
    }

    @Override
    public void init() {
        List<ChaosBean> list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            list.add(new Bean());
        }
        mRecyclerView.setAdapter(ChaosAdapter.createAdapter(list, new BaseChaosItem() {
            @Override
            public void onBindViewHolder(@NonNull ChaosViewHolder holder, int position, ChaosBean bean) {

            }

            @Override
            public ChaosViewHolder createViewHolder(@NonNull ViewGroup parent) {
                return new ChaosViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.chaos_default_item, parent, false));
            }

            @Override
            public int getChaosItemType() {
                return 1;
            }
        }));
    }

    @Override
    V getView() {
        return (V) mRecyclerView;
    }


    class Bean implements ChaosBean {
        @Override
        public int getChaosItemType() {
            return 1;
        }
    }
}
